package com.kurtphpr.sistemas.cliente;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.kurtphpr.sistemas.cliente.Cliente;
import com.kurtphpr.sistemas.util.HibernateUtil;

public class ClienteDAO {

	public void salvar(Cliente u) {
		Session sessao = null;
		Transaction tx = null;
		try {
			sessao = HibernateUtil.getSession();
			tx = sessao.beginTransaction();
			sessao.save(u);
			tx.commit();
		} catch (Exception ex) {
			tx.rollback();
			ex.printStackTrace();
		} finally {
			if (sessao != null) {
				try {
					sessao.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}
}
